package com.xy.tianyu.module.novel.adapter

import androidx.recyclerview.widget.GridLayoutManager
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xy.tianyu.R
import com.xy.tianyu.module.novel.bean.CompetitiveManMultipleItem
import com.xy.tianyu.module.novel.bean.CompetitiveRecommendMultipleItem
import com.youth.banner.indicator.CircleIndicator
import kotlinx.android.synthetic.main.item_competitive_man_two.view.*
import kotlinx.android.synthetic.main.item_competitive_recommend_top.view.*

/**
 * @time 2020/11/27 16:18
 * @class 描述:
 */
class CompetitiveManMutilpleAdapter (data:MutableList<CompetitiveManMultipleItem>) :
    BaseMultiItemQuickAdapter<CompetitiveManMultipleItem, BaseViewHolder>(data) {
    init {
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_ONE, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_TWO, R.layout.item_competitive_man_two)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_THREE, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_FOUR, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_FIVE, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_SIX, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_SEVEN, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_EIGHT, R.layout.item_competitive_recommend_top)
        addItemType(CompetitiveManMultipleItem.COMPETITIVE_MAN_NINE, R.layout.item_competitive_recommend_top)
    }
    override fun convert(holder: BaseViewHolder, item: CompetitiveManMultipleItem) {
        val  data = item.data
        when (item.itemType){
            CompetitiveManMultipleItem.COMPETITIVE_MAN_ONE -> {
                with(holder.itemView.banner) {
                    adapter = CompetitiveRecommendBannerAdapter(data.list)
                    indicator = CircleIndicator(context)
                    start()
                }
            }

            CompetitiveManMultipleItem.COMPETITIVE_MAN_TWO -> {
                val twoAdapter = CompetitiveManTwoAdapter(R.layout.item_competitive_man_two_child,data.list)
                with(holder.itemView.ry_man_innovate){
                    layoutManager = GridLayoutManager(context,5)
                    adapter = twoAdapter
                }
            }
        }
    }
}